@extends('common.base-master')

@section('html-head')
@endsection

@section('html-body')
    <div class="exconfirm-page">
        <div class="confirm-msg">
            <div class="product-count-box">
                <div class="product-img">
                    <img  src="@if(!is_null($order->good)){{route('Api.Image.ShowPX',['id'=>$order->good->thumb_id,'px'=>'300px'])}}@else {{url('images/default_product.png')}}@endif" alt="">
                </div>
                <div class="product-name">@if($order && $order->good){{$order->good->name}}@endif</div>
                <div class="product-price">单价：<span>@if($order && $order->good){{$order->good->coin}}@endif</span>波罗币</div>
                <div class="count-num">×@if($order){{$order->num}}@endif</div>
                <div class="total-price">
                    总价：<span>@if($order){{$order->coin}}@endif</span>波罗币
                </div>
            </div>
            <div class="border"></div>
            <div class="user-info">
                <div class="info-item">
                    姓名：@if($order){{$order->realname}}@endif
                </div>
                <div class="info-item">
                    手机：@if($order){{$order->phone}}@endif
                </div>
                <div class="info-item">
                    QQ：@if($order){{$order->qq}}@endif
                </div>
                <div class="info-item">
                    微信：@if($order){{$order->wechat}}@endif
                </div>
                <div class="info-item">
                    地址：@if($order){{$order->address}}@endif
                </div>
                <div class="info-item">
                    手机型号：@if($order){{$order->attr_name}}@endif
                </div>
                <div class="confirm-btn" data-id="@if($order){{$order->id}}@endif">提交订单</div>
            </div>
        </div>
        <div class="alert-container hidden">
            <div class="alert-box">
                <span class="bg-tick_b_icon"></span>
                <span class="alert-msg">商品兑换成功</span>
                <span class="alert-tips">我们将在7个工作日内为您寄出商品请注意查收~</span>
            </div>
        </div>
    </div>
    <script>
        $(document).ready(function () {
            $('.confirm-btn').click(function () {
                var id = $(this).data('id');
                $.ajax({
                    url:"{{route('Api.Good.confirmOrder')}}",
                    type:'post',
                    dataType:'json',
                    data:{
                        order_id:id
                    },
                    success:function (obj) {
                        if(obj.level == 'success'){
                            $('.alert-container').removeClass('hidden');
                            setTimeout(function(){
                                window.location.href="{{route('Home.User.myexchange')}}?type=dfh";
                            }, 3000);
                        }else {
                            $.toast(obj.message,"forbidden");
                        }
                    },
                    error:function (obj) {
                        console.log(obj);
                    }
                });
            });
        })
    </script>
@endsection